package com.commerceE.managedBean;


import javax.faces.bean.*;

import org.primefaces.component.menuitem.MenuItem;
import org.primefaces.model.DefaultMenuModel;
import org.primefaces.model.MenuModel;

import com.commerceE.util.FacesUtil;


@ManagedBean
@SessionScoped
public class NavBean {
	private String page = "";

	private MenuModel simpleMenuModel = new DefaultMenuModel();
	
	public NavBean(){
		MenuItem item1 = new MenuItem();
		item1.setValue("leftMenu");
		item1.setUpdate(":centerForm:centerContentPanel");
		item1.addActionListener(FacesUtil.createMethodActionListener("#{navBean.setPage('')}", Void.class,
                new Class[] {}));
		
		MenuItem item2 = new MenuItem();
		item2.setValue("hello");
		item2.setUpdate(":centerForm:centerContentPanel");
		item2.addActionListener(FacesUtil.createMethodActionListener("#{navBean.setPage('')}", Void.class,
                new Class[] {}));
		
		MenuItem item3 = new MenuItem();
//		item3.setId("Dynamic Menuitem3333");
		item3.setValue("Dynamic Menuitem333");
		item3.setUpdate(":centerForm:centerContentPanel");
		item3.addActionListener(FacesUtil.createMethodActionListener("#{navBean.setPage('')}", Void.class,
                new Class[] {}));
		
		simpleMenuModel.addMenuItem(item1);
		simpleMenuModel.addMenuItem(item2);
		simpleMenuModel.addMenuItem(item3);
	}

	public String getPage() {
		return page;
	}

	public void setPage(String page) {
		System.out.println("Set the page to :" + page);
		this.page = page;
	}

	public MenuModel getSimpleMenuModel() {
		return simpleMenuModel;
	}

	public void setSimpleMenuModel(MenuModel simpleMenuModel) {
		this.simpleMenuModel = simpleMenuModel;
	}

}
